<template>
  <el-input v-model="model" :placeholder="placeholder"/>
</template>
<script setup>
import {computed, defineProps, ref} from 'vue';
import {DefaultFieldDefinition} from '@/components/form/DefaultFormDefinition';
import {handleLikeParam, isEmpty} from '@/utils/CommonUtils';

const props = defineProps({
  field: {
    type: Object,
    default() {
      return DefaultFieldDefinition;
    }
  }
});
const model = ref();

function resetField() {
  model.value = undefined;
}

function getSearchFieldValue(searchData) {
  if (isEmpty(model.value)) return;
  searchData.like.push({
    fieldName: props.field.tableFieldName + '_dictText',
    value: handleLikeParam(model.value)
  });
}

const placeholder = computed(() => {
  if (isEmpty(props.field.id)) return '';
  return `请输入${props.field.alias ? props.field.alias : props.field.showName}`;
});


defineExpose({
  getSearchFieldValue,
  resetField
});
</script>
